﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using myBoard.App.MagnetStore;

namespace myBoard.App.Components.MagnetsStore.ViewsModels
{
    public class MagnetCommentViewModel : INotifyPropertyChanged
    {
        private MagnetComment _magnetComment;
        public int ID
        {
            get
            {
                return _magnetComment.ID;
            }
        }
        public string Title 
        {
            get
            { return _magnetComment.Title; }
            set
            { 
                _magnetComment.Title = value;
                RaisePropertyChanged("Title");
            }
        }
        public string Description 
        {
            get
            { return _magnetComment.Description; }
            set
            {
                _magnetComment.Description = value;
                RaisePropertyChanged("Description");
            }
        }

        public int? Rating 
        {
            get
            { return _magnetComment.Rating; }
            set
            {
                _magnetComment.Rating = value;
                RaisePropertyChanged("Rating");
            }
        }

        public DateTime SubmissionDate
        {
            get
            { return _magnetComment.SubmissionDate; }
        }

        public UserViewModel Author
        {
            get
            { return new UserViewModel(_magnetComment.Author); }
        }


        public MagnetCommentViewModel(MagnetComment magnetComment)
        {
            _magnetComment = magnetComment;            
        }

        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        } 
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
